Skip to content

[Zero-1016] WEEK 02 solutions#2694

Open
Zero-1016 wants to merge 6 commits into
DaleStudy:mainfrom
Zero-1016:week-2
Open

[Zero-1016] WEEK 02 solutions#2694
Zero-1016 wants to merge 6 commits into
DaleStudy:mainfrom
Zero-1016:week-2

Conversation

@Zero-1016

@Zero-1016 Zero-1016 commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

답안 제출 문제

작성자 체크 리스트

  • Projects의 오른쪽 버튼(▼)을 눌러 확장한 뒤, Week를 현재 주차로 설정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 StatusIn Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

검토자 체크 리스트

Important

본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!

  • 바로 이전에 올라온 PR에 본인을 코드 리뷰어로 추가해주세요.
  • 본인이 검토해야하는 PR의 답안 코드에 피드백을 주세요.
  • 토요일 전까지 PR을 병합할 수 있도록 승인해주세요.

@dalestudy

dalestudy Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

📊 Zero-1016 님의 학습 현황

이번 주 제출 문제

문제 난이도 유형 분석
3sum Medium ✅ 의도한 유형
climbing-stairs Easy ✅ 의도한 유형
product-of-array-except-self Medium ✅ 의도한 유형
valid-anagram Easy ✅ 의도한 유형
validate-binary-search-tree Medium ✅ 의도한 유형

누적 학습 요약

  • 풀이한 문제: 5 / 75개
  • 이번 주 유형 일치율: 100% (5문제 중 5문제 일치)

문제 풀이 현황

카테고리 진행도 완료
Heap ■■□□□□□ 1 / 3 (Medium 1)
Array ■□□□□□□ 2 / 10 (Easy 2)
Graph ■□□□□□□ 1 / 8 (Medium 1)
Dynamic Programming ■□□□□□□ 1 / 11 (Medium 1)
Binary □□□□□□□ 0 / 5 ← 아직 시작 안 함
Interval □□□□□□□ 0 / 5 ← 아직 시작 안 함
Linked List □□□□□□□ 0 / 6 ← 아직 시작 안 함
Matrix □□□□□□□ 0 / 4 ← 아직 시작 안 함
String □□□□□□□ 0 / 10 ← 아직 시작 안 함
Tree □□□□□□□ 0 / 14 ← 아직 시작 안 함

🤖 이 댓글은 GitHub App을 통해 자동으로 작성되었습니다.

🔢 API 사용량 (gpt-5-nano)
요청 입력 토큰 출력 토큰 합계 비용
1 438 37 475 $0.000037
2 1,742 148 1,890 $0.000146
3 2,336 232 2,568 $0.000210
4 2,329 232 2,561 $0.000209
합계 6,845 649 7,494 $0.000602

@github-actions github-actions Bot added the ts label Jul 2, 2026
@Zero-1016 Zero-1016 moved this from Solving to In Review in 리트코드 스터디 8기 Jul 2, 2026
@Zero-1016 Zero-1016 moved this from In Review to Solving in 리트코드 스터디 8기 Jul 2, 2026
Comment thread valid-anagram/Zero-1016.ts Outdated

// 문자열 s와 t의 빈도수를 비교
for (const [key, value] of sMap) {
if (value !== tMap.get(key) || !tMap.has(key)) return false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 has() 체크가 없어도 동작하지 않을까요? key가 없을 때 get()은 undefined를 반환하고, value는 number이므로 value !== undefined가 true가 되어 return false가 반환될 것 같습니다. 조건을 하나 줄이면 더 간결해질 것 같아서 의견드려봅니다.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 부분 간결하게 수정이 가능했네요 확인 감사합니다 :) refactor: has 검사 제거 리뷰 반영

@Zero-1016 Zero-1016 moved this from Solving to In Review in 리트코드 스터디 8기 Jul 3, 2026

const dp = new Array(n).fill(0);

dp[0] = 1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dp[i]가 0부터 시작하다보니, 마치 0개 계단의 경우 1칸 이동을 나타내는 것처럼 느껴집니다.
저도 인덱스를 0부터 자주 사용하는데요. 이 경우, 인덱스를 1부터 사용하면 dp[i] = i칸 계단의 답으로 읽혀 더 직관적이고, base case 설정에 따라 early return도 자연스럽게 제거할 수 있을 것 같다는 의견을 드려봅니다..!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

의견 감사합니다! 사실 저도 dp[1] 부터 사용하는걸 생각하긴 했는데요. dp[0]을 비워두면 실제로 쓰이지 않는 값이 배열에 남는 게 어색해서, 슬롯을 전부 의미 있게 채우는 쪽(dp[i] = i+1칸의 답)으로 작성했어요. 공간 차이는 미미하지만, "배열의 모든 원소가 유효한 답"이라는 일관성을 유지하고 싶었습니다.

Comment thread 3sum/Zero-1016.ts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

  • 패턴: Two Pointers, Sorting
  • 설명: 코드는 정렬 후 두 포인터(left, right)를 사용해 삼중합의 합이 0이 되도록 탐색합니다. 중복 제거를 위해 같은 값 건너뛰기 로직도 포함되어 있어 투 포인터 패턴이 핵심입니다.

📊 시간/공간 복잡도 분석

ℹ️ 이 파일에는 5가지 풀이가 포함되어 있어 각각 분석합니다.

풀이 1: threeSum — Time: ✅ O(n²) → O(n^2) / Space: ❌ O(log n) → O(1)
유저 분석 실제 분석 결과
Time O(n²) O(n^2)
Space O(log n) O(1)

피드백: 정렬과 투 포인터를 이용해 모든 3합을 찾고, 중복을 양 끝에서 건너뛰는 방식으로 제거합니다.

개선 제안: 현재 구현이 적절해 보입니다.

풀이 2: climbStairs — Time: ❌ O(n²) → O(n) / Space: ❌ O(log n) → O(n)
유저 분석 실제 분석 결과
Time O(n²) O(n)
Space O(log n) O(n)

피드백: 앞선 두 수의 합으로 현재의 경우의 수를 구하는 일반적인 DP 풀이입니다.

개선 제안: 현재 구현이 적절해 보입니다.

풀이 3: productExceptSelf — Time: ❌ O(n²) → O(n) / Space: ❌ O(log n) → O(1)
유저 분석 실제 분석 결과
Time O(n²) O(n)
Space O(log n) O(1)

피드백: 두 방향 누적곱으로 모든 원소의 곱을 구하는 표준 풀이입니다.

개선 제안: 현재 구현이 적절해 보입니다.

풀이 4: isAnagram — Time: ❌ O(n²) → O(n) / Space: ❌ O(log n) → O(1)
유저 분석 실제 분석 결과
Time O(n²) O(n)
Space O(log n) O(1)

피드백: 두 맵을 사용해 빈도수를 비교하되, 배열 기반 카운트가 더 빠르고 간결합니다.

개선 제안: 현재 구현이 적절해 보입니다.

풀이 5: isValidBST — Time: O(n) / Space: O(n)
복잡도
Time O(n)
Space O(n)

피드백: 각 노드에 대해 유효한 범위를 추적하는 표준 방식입니다.

개선 제안: 현재 구현이 적절해 보입니다.

💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제가 작성한 복잡도랑 다르게 표기가 되어있네요 :(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

  • 패턴: Dynamic Programming
  • 설명: 클라이밍 스탯 문제는 각 계단 수를 두 가지 방법으로 오르는 경우의 합으로 누적 최댓값을 구하는 전형적인 DP 문제이며, 점화식으로 순서를 계산합니다.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

  • 패턴: Two Pointers, Hash Map / Hash Set
  • 설명: 왼쪽과 오른쪽에서 곱을 누적하는 방식으로 각 원소를 제외한 곱을 구하므로 두 포인터처럼 양 방향으로 누적하는 아이디어가 보이고, 직접적인 해시 자료구조의 사용은 없지만 두 방향 누적 방식이 핵심 패턴으로 작동합니다.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

  • 패턴: Hash Map / Hash Set, Greedy
  • 설명: 두 문자열의 문자 빈도를 해시 맵으로 카운트하고, 이를 비교하여 anagram 여부를 판단한다. 해시 맵을 활용한 빈도 비교 패턴이 핵심이다.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏷️ 알고리즘 패턴 분석

  • 패턴: Depth-First Search, Binary Search, Monotonic Stack, Hash Map / Hash Set
  • 설명: 반복적 DFS로 트리 노드를 순회하며 각 노드의 값이 부모가 정한 범위 안에 있는지 검사한다. 이와 동시에 BST의 성질을 만족하는지 확인하며, 범위 갱신은 자식 노드 방향에 따라 min/max를 업데이트한다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants